package com.uni.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.uni.db.GenericService;
import com.uni.domain.Course;

@Controller
@RequestMapping("/courseView.htm")
@SessionAttributes("course")
public class CourseView {
    @Autowired
	@Qualifier("courseService")
	private GenericService<Course> courseService;

	@RequestMapping(method = RequestMethod.GET)
    public String setupForm(@RequestParam("id") Long id, ModelMap model) {
        Course course = courseService.get(id);
        model.addAttribute("course", course);
        return "courseView";
    }
}